import requests


g_url = "http://192.168.217.138:8080"
login_path = "/v7/login"
login_data = {
    "loginname":"guest",
    "password":"guest"
}
header = {"Content-Type":"Application/json"}
login_response = requests.post(url = g_url+login_path,json=login_data,headers=header)
login_response.encoding = "UTF-8"
l_code = login_response.status_code
l_text = login_response.json()
print('登录成功')
print('返回值',l_code)
print('')
token = l_text['token']

#新建员工信息
auth = {"Authorization": f"Bearer {token}"}
p_path = "/pimpeople"
p_data = {"pimpersonname":"王小白","ygbh":"20240801-01","zjlx":"10","zjhm":"41000199009091234","lxdh":"13020201234","ygzt":"30"}
p_response = requests.post(url = g_url + p_path,json=p_data,headers=auth)
p_code = p_response.status_code
if p_code == 200:
    print('新建员工信息成功')
    print('返回值', p_code)
    print('')
else:
    print('新建员工信息失败')
    print('返回值',p_code)
    print('')

#上传员工头像
sauth = {"Authorization": f"Bearer {token}"}
s_path = "/ibizutil/upload"
with open("D:/tupian/1.jpg", "rb") as file:
    s_files = {'file': ('1.jpg', file, 'image/jpeg')}
    s_response = requests.post(url=g_url + s_path, files=s_files, headers=sauth)
s_code = s_response.status_code
if s_code == 200:
    print('上传员工头像成功')
    print('返回值', s_code)
    print('')
else:
    print('上传员工头像失败')
    print('返回值',s_code)
    print('')

#保存员工信息
sauth = {"Authorization": f"Bearer {token}"}
b_path = "/pimpeople/34f91ff121e03b8428c2c24b1aac34d0"
b_data = {"updatedate": "2019-02-21 23:05:59","pimpersonid": "0013542A-5C63-4BD7-964A-5B8E74D0379D","pimpersonname":"马**","ygbh": "1921****","zjlx": "10","ygzt": "30","zjhm": "3353635326********","lxdh": "159182*****"}
b_response = requests.put(url = g_url + b_path,json=b_data,headers=sauth)
b_code = b_response.status_code
if b_code == 200:
    print('保存员工信息成功')
    print('返回值', b_code)
    print('')
else:
    print('保存员工信息失败')
    print('返回值',b_code)
    print('')

#新增教育信息
sauth = {"Authorization": f"Bearer {token}"}
j_path = "/pimpeople/34f91ff121e03b8428c2c24b1aac34d0/pimeducations"
j_data = {"srfparentdename": "OrmOrg","srfparentkey": "64BCDCC1-24AA-42E4-AC7A-FB6F242F3FF1","sxzy": "土木工程","byyx": "清华大学","btz": "微信图片.jpg","pimpersonid": "64BCDCC1-24AA-42E4-AC7A-FB6F242F3FF1","xl": "01","jssj": "2024-07-02","xkml": "0BD50F57-DD0D-4BFE-99F1-6569F0EBA17C","sfdyxl": "10","xxxz": "10","xllx": "01"}
j_response = requests.post(url = g_url + j_path,json=j_data,headers=sauth)
j_code = j_response.status_code
if j_code == 200:
    print('新增教育信息成功')
    print('返回值',j_code)
    print('')
else:
    print('新增教育信息失败')
    print('返回值',j_code)
    print('')

#新增工作履历
sauth = {"Authorization": f"Bearer {token}"}
ll_path = "/pimpeople/34f91ff121e03b8428c2c24b1aac34d0/pimworkhistories"
ll_data = {"rzkssj": "2024-07-01","ormpostname": "讲师","cfplx": "10","pimpersonid": "64BCDCC1-24AA-42E4-AC7A-FB6F242F3FF1","ormdutyname": "讲师","ormorgname": "清华大学","ormorgsectorname": "数学组","experience": "10","rzjssj": "2024-07-06"}
ll_response = requests.post(url = g_url + ll_path,json=ll_data,headers=sauth)
ll_code = ll_response.status_code
if ll_code == 200:
    print('新增工作履历成功')
    print('返回值',ll_code)
    print('')
else:
    print('新增工作履历失败')
    print('返回值',ll_code)
    print('')

#新增奖惩信息
sauth = {"Authorization": f"Bearer {token}"}
jc_path = "/pimpeople/34f91ff121e03b8428c2c24b1aac34d0/pimrewardpunishments"
jc_data = {"pimrewardpunishmentname": "奖励","pimpersonid": "e2a8940719bf014837388ed2a3155284","lx": "REWARD","jcjb": "40","jcje": 10000,"jlsj": "2024-07-10","department": "董事会","jlss": "10","jcsj": "有功","bz": "无"}
jc_response = requests.post(url = g_url + jc_path,json=jc_data,headers=sauth)
jc_code = jc_response.status_code
if jc_code == 200:
    print('新增奖惩信息成功')
    print('返回值',jc_code)
else:
    print('新增奖惩信息失败')
    print('返回值',jc_code)

